
import { useMemo } from 'react'
// eslint-disable-next-line no-unused-vars
const withFilter = (WrappedComponent) => {
  return props => {
     const { list, filter, ...restProps } = props;
    const filterList =  useMemo(() => {
      
      if (filter === 'all') {
        return list
      }
      if (filter === 'done') {
        return list.filter(item => item.status === 0)
      }
      // 未完成
      if (filter === 'pending') {
        return list.filter(item => item.status === undefined)
      }

     
  
    }, [list, filter])
   


    return (<WrappedComponent {...restProps} filterList={filterList} />)
  }
}
export default withFilter
